from urllib import request,parse

url = "https://www.python.org"
response = request.urlopen(url)
# 下面这行代码有错误，运行不了
#print(response.read().decode('utf-8'))

#print(response.read().decode('utf8'))

print(type(response))

# 传参，我需要搭建自己的服务器吗？不需要

url = 'http://www.httpbin.org/post'



data = {
    "name":"wuqiang",
    "password":"123"
}

urlencode = parse.urlencode(query=data)

print(f"转化后的字符串{urlencode}")

data_bytes = bytes(urlencode,encoding="utf-8")


try:
    response = request.urlopen(url,data=data_bytes,timeout=0.1)
    print(response.read().decode('utf-8'))
except:
    print("超时了")

